<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});
Route::group(['middleware' => ['web']], function () {
    Route::get('/welcome','AgentController@index');
    Route::any('/import','ImportController@index');
    Route::any('/basic','BasicController@index');
    Route::any('/tran','TranController@index');
    Route::any('/basic/set','BasicController@set');
    Route::any('/basic/delete/{id}','BasicController@delete');
    Route::any('/sellog','LogController@index');
    Route::any('/profit','ProfitController@index');
    Route::group(['prefix' => 'agent'], function () {
        Route::get('/', 'AgentController@index')->name('agent');
        Route::any('/agentlist/{id}', 'AgentController@agentlist');
        Route::any('/close/{id}', 'AgentController@close');
        Route::any('/open/{id}', 'AgentController@open');
        Route::get('/upgrade/{id}', 'AgentController@upgrade');
        Route::post('/upgrade/{id}', 'AgentController@postupgrade');
        Route::any('/pay/{id}', 'AgentController@pay');
        Route::any('/setremain', 'AgentController@setremain');
    });
    Route::group(['prefix' => 'balance'], function () {
        Route::get('/', 'BalanceController@index');
        Route::get('/needpay', 'BalanceController@needpay');
    });
    Route::group(['prefix' => 'customer'], function () {
        Route::get('/', 'CustomerController@index');
        Route::get('/index', 'CustomerController@index');
        Route::get('/active/{id}', 'CustomerController@active');
        Route::post('/settran', 'CustomerController@settran');
    });
    /**
     * 登录
     */
    Route::get('/login', 'LoginController@login');
    Route::post('/login', 'LoginController@postLogin');
    Route::get('/logout', function () {
        session()->flush();
        return redirect('/login');
    });
});
